import { useState, memo } from 'react';
import styles from '../index.scss';
import { Select } from 'antd';
import ChartGather from '@/components/ChartGather';
const { Option } = Select;

function IndexPage(props: any) {
    const [currentIndex, setcurrentIndex] = useState(0);
    const { charList, index } = props;
    const items = charList[currentIndex][index] as any;
    return (
        <div key={items?.id} className={styles.charDiv}>
            <div>
                <div style={{ float: 'left' }}>{items?.name}</div>
                <div style={{ float: 'right' }}>
                    <Select
                        defaultValue={0}
                        style={{ width: 120 }}
                        onChange={(value) => {
                            setcurrentIndex(value);
                        }}
                        value={currentIndex}
                    >
                        <Option value={0} key={0}>
                            一月
                        </Option>
                        <Option value={1} key={1}>
                            半年
                        </Option>
                        <Option value={2} key={2}>
                            一年
                        </Option>
                    </Select>
                </div>
            </div>
            <ChartGather {...charList[currentIndex][index]} />
        </div>
    );
}
export default memo(IndexPage);
